home *** CD-ROM | disk | FTP | other *** search
- /*
- * sharpSpecular.sl
- *
- * Surface shader implementing sharp specular highlight model,
- * stolen directly from the Advanced RenderMan book.
- */
-
- surface sharpSpecular(float Ka=1, Kd=1, Ks=1, sharpness = .1,
- roughness=.1; color specularcolor = 1) {
- normal Nf = normalize(faceforward(N, I));
- vector In = normalize(I);
- float w = .18 * (1-sharpness);
- illuminance(P, Nf, PI/2) {
- vector Ln = normalize(L);
- vector H = normalize(Ln + -In);
- Ci += Cl * specularcolor * Ks *
- smoothstep(.72-w, .72+w, pow(max(H . Nf, 0), 1/roughness));
- }
- Ci += Ka * ambient() + Kd * diffuse(Nf);
- Ci *= Cs;
- }
-